﻿@page
@model FangChanCrm.Views.BuMen.BuMenXiuGaiModel
@{
}
<script src="~/admui-13945148017-1592211513218/public/themes/global/js/components/bootstrap-datepicker.min.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/bootstrap-datepicker/bootstrap-datepicker.min.js"><</script>
<script src="~/admui-13945148017-1592211513218/public/vendor/bootstrap-datepicker/bootstrap-datepicker.zh-CN.min.js"></script>
<link href="~/admui-13945148017-1592211513218/public/vendor/bootstrap-datepicker/bootstrap-datepicker.min.css" rel="stylesheet" />
<link href="~/admui-13945148017-1592211513218/public/css/examples/tables/datatable.css" rel="stylesheet" />
<link href="~/admui-13945148017-1592211513218/public/vendor/datatables-responsive/dataTables.responsive.css" rel="stylesheet" />
<link href="~/admui-13945148017-1592211513218/public/vendor/datatables-bootstrap/dataTables.bootstrap4.css" rel="stylesheet" />
<link href="~/admui-13945148017-1592211513218/public/vendor/datatables-responsive/dataTables.responsive.css" rel="stylesheet" />
<script src="~/admui-13945148017-1592211513218/public/vendor/datatables/jquery.dataTables.min.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/datatables-bootstrap/dataTables.bootstrap.min.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/datatables-bootstrap/dataTables.bootstrap4.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/datatables-responsive/dataTables.responsive.min.js"></script>
<form id="form1" runat="server">
    <div class="page-container" id="admui-pageContent">
        <div class="page animation-fade page-forms">
            <div class="page-header">
                <h1 class="page-title" id="biao1">修改部门</h1>
                <ol class="breadcrumb">
                    <li class="breadcrumb-item">
                        <a class="icon wb-home" href="javascript:;">部门管理</a>
                    </li>
                    <li class="breadcrumb-item active" id="biao2">修改部门</li>
                </ol>
                <label style="display:none" id="lbl_Id"></label>
            </div>
            <div class="page-content">
                <div class="panel">
                    <div class="panel-body container-fluid">
                        <h4 class="example-title"></h4>
                        <div class="row">
                            <div class="form-group col-sm-1"></div>
                            <div class="form-group col-sm-5">
                                <label class="control-label" for="inputBasicPassword">部门名称</label>
                                <input type="text" class="form-control" id="ipt_BuMenMingCheng" name="" placeholder="部门名称" autocomplete="off" />
                            </div>
                            <div class="form-group col-sm-5">
                                <label class="control-label" for="inputBasicPassword">公司名称</label>
                                <select class="form-control" id="slt_GongSiMingCheng" name="" data-fv-notempty="true" data-fv-field="requiredSelect"></select>
                            </div>
                            <div class="form-group col-sm-1"></div>
                            <div class="form-group col-sm-1"></div>
                            <div class="form-group col-sm-5">
                                <label class="control-label" for="inputBasicNickName" style="float: left;">部门模式</label>
                                <br />
                                <div class="radio-custom radio-primary" style="float: left;">
                                    <input type="radio" id="PuTongBuMen" value="普通部门" name="inputRadios"  />
                                    <label for="PuTongBuMen">普通部门</label>
                                </div>
                                <div class="radio-custom radio-primary" style="float: left; margin-left: 20%;">
                                    <input type="radio" id="ZhanQuBuMen" name="inputRadios" value="战区部门" />
                                    <label for="ZhanQuBuMen">战区部门</label>
                                </div>
                            </div>
                            <div class="form-group col-sm-1"></div>
                            <div class="form-group col-sm-6 row" style="padding-left:70px">
                                <div class="form-group col-sm-1"></div>
                                <div class="form-group col-sm-4" style="padding-top: 70px;">
                                    <button type="button" id="anniu1" class="btn btn-block btn-success" style="width: 100%; margin-left: 15px; float: left;" onclick="XiuGaiBuMen()">修改部门</button>
                                </div>


                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>
</form>
<script type="text/javascript" language="javascript" class="init">
    $(document).ready(function () {
        $("#SpanGongSi").click();
        BangDingGongSi();
        HuiBangShuJu();
    });
    function XiuGaiBuMen() {
        var ipt_BuMenMingCheng = $("#ipt_BuMenMingCheng").val();
        var slt_GongSiMingCheng = $("#slt_GongSiMingCheng").val();
        var BuMenMeShi = $("input:radio[name='inputRadios']:checked").val();
        if (ipt_BuMenMingCheng == "") {
            alert("部门名称不能为空");
        } else if (slt_GongSiMingCheng == 0) {
            alert("公司名称不能为空");
        } else {
            var id = GetQueryString("id");
            $.ajax({
                url: "../BuMen/XiuGaiBuMen",
                data: { ipt_BuMenMingCheng: ipt_BuMenMingCheng, slt_GongSiMingCheng: slt_GongSiMingCheng, BuMenMeShi: BuMenMeShi, Id: id },
                type: "post",
                dataType: "text",
                success: function (response) {
                    if (response == "success") {
                        alert('提交成功');
                    } if (response == "error") {
                        alert('提交失败');
                    }
                }
            });
        }
    }

    function HuiBangShuJu() {
        var id = GetQueryString("id");

        $.ajax({
            type: 'post',
            url: '../BuMen/HuiBangShuJu',
            dataType: 'json',
            async: true,
            data: { "id": id },
            success: function (result) {
                //alert(result);
                var json = result;
                $.each(json, function (index) {
                    $("#ipt_BuMenMingCheng").val(json[index].BuMenMingCheng);
                    $("#slt_GongSiMingCheng").val(json[index].GongSiId);
                    if (json[index].ZhanQuZhuangTai == "普通部门") {
                        $("#PuTongBuMen").attr("checked","checked");
                    } else if (json[index].ZhanQuZhuangTai == "战区部门") {
                        $("#ZhanQuBuMen").attr("checked", "checked");
                    }
                })
            }
        });
    }

    function BangDingGongSi() {
        $.ajax({
            type: 'POST',
            url: '../BuMen/BangDingGongSi',
            async: false,
            dataType: 'json',
            success: function (date) {
                var ddl = $("#slt_GongSiMingCheng");
                ddl.append("<option value='0'>请选择</option>");
                $(date).each(function (key) {
                    var opt = $("<option></option>").text(date[key].GongSiMingChenhg).val(date[key].Id);
                    ddl.append(opt);
                })
            },
        })
    }
    //获取数据方法
    function GetQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]); return null;
    }
</script>